<template>
  <div class="loginbox">
    <el-form label-width="80px" :model="userInfo">
      <el-form-item label="账号">
        <el-input v-model="userInfo.username"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="userInfo.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button style="width: 200px" @click="login">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "login",
  data() {
    return {
      userInfo:{
        username:"",
        password:""
      }
    }
  },
  methods: {
    login(){
      this.$store.dispatch('login',this.userInfo).then(()=>{
        this.$router.push('/home')
      })
    }
  }
}
</script>

<style scoped>
.loginbox{

}
</style>
